package com.dailyblue.java.spring.cloud.example.sentinel.product.controller;

import com.dailyblue.java.spring.cloud.example.commons.util.JsonResult;
import com.dailyblue.java.spring.cloud.example.commons.util.ResultTool;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/product")
public class ProductController {

    @GetMapping("/a")
    public JsonResult a() throws Exception {
        Thread.sleep(2000);
        return ResultTool.success("aaa");
    }

    @GetMapping("/b")
    public JsonResult b() throws Exception {
        return ResultTool.success("bbb");
    }

    @GetMapping("/c/{index}")
    public JsonResult c(@PathVariable Integer index) throws Exception {
        String[] array = {"aa", "bb"};
        String s = array[index];
        System.out.println(s);
        return ResultTool.success(s);
    }
}
